package com.ruoyi.project.reportSystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.reportSystem.domain.AttendanceRecordImage;
import com.ruoyi.project.reportSystem.service.IAttendanceRecordImageService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 图片查看Controller
 * 
 * @author wangshuo
 * @date 2021-01-28
 */
@RestController
@RequestMapping("/reportSystem/image")
public class AttendanceRecordImageController extends BaseController
{
    @Autowired
    private IAttendanceRecordImageService attendanceRecordImageService;

    /**
     * 查询图片查看列表
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:image:list')")
    @GetMapping("/list")
    public TableDataInfo list(AttendanceRecordImage attendanceRecordImage)
    {
        startPage();
        List<AttendanceRecordImage> list = attendanceRecordImageService.selectAttendanceRecordImageList(attendanceRecordImage);
        return getDataTable(list);
    }

    /**
     * 导出图片查看列表
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:image:export')")
    @Log(title = "图片查看", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AttendanceRecordImage attendanceRecordImage)
    {
        List<AttendanceRecordImage> list = attendanceRecordImageService.selectAttendanceRecordImageList(attendanceRecordImage);
        ExcelUtil<AttendanceRecordImage> util = new ExcelUtil<AttendanceRecordImage>(AttendanceRecordImage.class);
        return util.exportExcel(list, "image");
    }

    /**
     * 获取图片查看详细信息
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:image:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(attendanceRecordImageService.selectAttendanceRecordImageById(id));
    }

    /**
     * 新增图片查看
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:image:add')")
    @Log(title = "图片查看", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AttendanceRecordImage attendanceRecordImage)
    {
        return toAjax(attendanceRecordImageService.insertAttendanceRecordImage(attendanceRecordImage));
    }

    /**
     * 修改图片查看
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:image:edit')")
    @Log(title = "图片查看", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AttendanceRecordImage attendanceRecordImage)
    {
        return toAjax(attendanceRecordImageService.updateAttendanceRecordImage(attendanceRecordImage));
    }

    /**
     * 删除图片查看
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:image:remove')")
    @Log(title = "图片查看", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(attendanceRecordImageService.deleteAttendanceRecordImageByIds(ids));
    }
}
